<template>
  <div class="loading">
      <div class="spinner">
        <div class="spinner-container container1">
          <div class="circle1"></div>
          <div class="circle2"></div>
          <div class="circle3"></div>
          <div class="circle4"></div>
        </div>
        <div class="spinner-container container2">
          <div class="circle1"></div>
          <div class="circle2"></div>
          <div class="circle3"></div>
          <div class="circle4"></div>
        </div>
        <div class="spinner-container container3">
          <div class="circle1"></div>
          <div class="circle2"></div>
          <div class="circle3"></div>
          <div class="circle4"></div>
        </div>
      </div>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  name: 'login',
  data() {
    return {
      name: '',
      password:''
    }
  },
  methods:{
    login(){
        let name=this.name
        let password=this.password

        let date={
            "grant_type": "password",
            "client_id": "game-admin",
            "client_secret": "0a0e2b7c0f223ff235810cbdc70f1ddd",
            "scope": "game_admin",
            "username": name,
            "password": password
        };
        var that=this;
        axios({
            method: 'post',
            url: this.$store.state.url+'/token',
            data: date,
          }).then(function(data){
            let token=data.data.data.access_token
 /*           console.log(token)
            let arr = token.split('');
            let passToken = "";
            for(var i=0;i<token.length;i++){
              passToken += arr[i].charCodeAt()*3;
              passToken += "/";
            }
            let lastToken=passToken.substring(0,passToken.length-1)
            console.log(lastToken)*/
            let d = new Date();
            d.setTime(d.getTime() + (604800000));
            let expires = "expires=" + d.toUTCString();
            document.cookie = "token" + "=" + token + "; " + expires;
            that.$store.dispatch("tokensync",token);
            //that.$router.push('/home')
          });
    }
  }
}

</script>

